home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ASTRNOMY / AA_51.ZIP / SUN.C < prev    next >
C/C++ Source or Header  |  1993-02-13  |  2KB  |  101 lines

  1. /* Calculate and display apparent coordinates of the sun at the
  2.  * time given by the external variables TDT, UT.
  3.  * Before calling this routine, the geometric position of the
  4.  * earth must be calculated and put in rearth[].
  5.  */
  6.  
  7. #include "kep.h"
  8. extern struct orbit earth;
  9. extern double rearth[];
  10. extern double coseps, sineps, dradt, ddecdt;
  11.  
  12. int dosun()
  13. {
  14. double r, x, y, t;
  15. double ecr[3], rec[3], pol[3];
  16. int i;
  17. double asin(), modtp(), sqrt(), cos(), sin();
  18.  
  19.  
  20. /* Display ecliptic longitude and latitude.
  21.  */
  22. for( i=0; i<3; i++ )
  23.     ecr[i] = -rearth[i];
  24. r = eapolar[2];
  25.  
  26. if( prtflg )
  27.     {
  28.     lonlat( ecr, TDT, pol );
  29.     }
  30.  
  31. /* Philosophical note: the light time correction really affects
  32.  * only the Sun's barymetric position; aberration is due to
  33.  * the speed of the Earth.  In Newtonian terms the aberration
  34.  * is the same if the Earth is standing still and the Sun moving
  35.  * or vice versa.  Thus the following is actually wrong, but it
  36.  * differs from relativity only in about the 8th decimal.
  37.  * It should be done the same way as the corresponding planetary
  38.  * correction, however.
  39.  */
  40. pol[2] = r;
  41. for( i=0; i<2; i++ )
  42.     {
  43.     t = pol[2]/173.1446327;
  44. /* Find the earth at time TDT - t */
  45.     kepler( TDT-t, &earth, ecr, pol );
  46.     }
  47. r = pol[2];
  48.  
  49. for( i=0; i<3; i++ )
  50.     {
  51.     x = -ecr[i];
  52.     y = -rearth[i];
  53.     ecr[i] = x;    /* position t days ago */
  54.     rec[i] = y;    /* position now */
  55.     pol[i] = y - x; /* change in position */
  56.     }
  57.  
  58. if( prtflg )
  59.     {
  60.     printf( "light time %.4fm,  ", 1440.0*t );
  61.     showcor( "aberration", ecr, pol );
  62.     }
  63.  
  64. /* Estimate rate of change of RA and Dec
  65.  * for use by altaz().
  66.  */
  67. deltap( ecr, rec, &dradt, &ddecdt );  /* see dms.c */
  68. dradt /= t;
  69. ddecdt /= t;
  70.  
  71.  
  72. /* There is no light deflection effect.
  73.  * AA page B39.
  74.  */
  75.  
  76. /* precess to equinox of date
  77.  */
  78. precess( ecr, TDT, -1 );
  79.  
  80. /* Nutation.
  81.  */
  82. epsiln( TDT );
  83. nutate( TDT, ecr );
  84.  
  85. showrd( "    Apparent:", ecr, pol );
  86.  
  87. /* Show it in ecliptic coordinates */
  88. if( prtflg )
  89.     {
  90.     y  =  coseps * ecr[1]  +  sineps * ecr[2];
  91.     y = zatan2( ecr[0], y );
  92.     printf( "Apparent longitude %.3lf deg\n", RTD*y );
  93.     }
  94.  
  95. /* Report altitude and azimuth
  96.  */
  97.  
  98. altaz( pol, UT );
  99. return(0);
  100. }
  101.